<%--
  Created by IntelliJ IDEA.
  User: 自由如风
  Date: 2018/7/3
  Time: 16:43
  To change this template use File | Settings | File Templates.
--%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:useBean id="student" class="com.online.entity.Student" scope="request"/>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html lang="en">
<!-- start: HEAD -->
<head>

    <title>STEC考试系统</title>

    <!-- start: META -->
    <meta charset="utf-8"/>
    <meta http-equiv='X-UA-Compatible' content="IE=edge,chrome=1"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta content="" name="description"/>
    <meta content="" name="author"/>
    <!-- end: META -->
    <link rel="shortcut icon" type="image/x-icon" href="${pageContext.request.contextPath}/resources/images/favicon.ico"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/fonts-useso/fonts.css">
    <!-- str: 主要css -->


    <!-- bootstrap 及 bootstrap拓展 -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/plugins/bootstrap-3.3.5-dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/plugins/bootstrap-3.3.5-dist/css/bootstrap-expand.css">
    <!-- end: 主要css -->
    <!-- start: 插件 css -->


    <!-- bootstrap 摸态框 -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/plugins/bootstrap-modal/css/bootstrap-modal.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/plugins/bootstrap-modal/css/bootstrap-modal-bs3patch.css">


    <!-- Font Awesome 图标字体 -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/plugins/font-awesome/css/font-awesome.min.css">


    <!-- iCheck 多选/单选插件 -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/plugins/iCheck/skins/all.css">
    <!-- magic-input 多选/单选插件 -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/plugins/magic-input/dist/magic-input.min.css">


    <!-- perfect-scrollbar 自定义滚动条 -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/plugins/perfect-scrollbar/src/perfect-scrollbar.css">


    <!-- animate css3动画 -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/plugins/animate.css/animate.min.css">


    <!-- animate css3动画 -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/plugins/select2-master/dist/css/select2.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/plugins/select2-bootstrap/dist/select2-bootstrap.css">


    <!-- 表单验证 -->
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/resources/plugins/jQuery-Validation-Engine-master/css/validationEngine.jquery.css">


    <!-- 日期插件 -->
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/resources/plugins/bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css">


    <!-- sweetalert 弹出框 -->

    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/plugins/sweetalert-0.5.x/lib/sweet-alert.css">


    <!-- ztree -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/plugins/zTree_v3/css/zTreeStyle/zTreeStyle.css">


    <!--[if lt IE 10]>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/plugins/uploadify/uploadify.css"/>
    <![endif]-->
    <!--[if gte IE 10]><!-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/plugins/uploadifive/uploadifive.css"/>
    <!--<![endif]-->
    <!-- end: 插件 css -->

    <!-- start: 框架 css -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/styles.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/styles-responsive.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/plugins.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/themes/theme-default.css" type="text/css" id="skin_color">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/print.css" type="text/css" media="print"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/quick-layout.css">
    <!-- end: 框架 css -->
    <!--[if lt IE 9]>
    <script src="${pageContext.request.contextPath}/resources/plugins/jQuery/jquery-1.11.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/resources/plugins/respond.min.js"></script>
    <script src="${pageContext.request.contextPath}/resources/plugins/excanvas.min.js"></script>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/ie8-patch.css">
    <![endif]-->
    <!--[if lt IE 10]>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/ie9-patch.css">
    <![endif]-->
    <!--[if gte IE 9]><!-->
    <script src="${pageContext.request.contextPath}/resources/plugins/jQuery/jquery-2.1.1.min.js"></script>
    <!--<![endif]-->


    <script>
        var basePath = 'https://www.scxszz.com:443';
        var nodePath = 'https://www.scxszz.com:443';
        var stageMenu = true;//分阶段菜单
        var tabModel = true;//是否启用Tab页
    </script>
</head>
<!-- start: body -->
<body class="single-page">
<div class="tabModel-content animated hide">


    <div class="col-md-10 col-md-offset-1">
        <h3 data-localize="frame_xtgl.mmxg_mmxg">添加学生</h3>
        <hr>

        <form method="post" id="myform">

            <div class="form-group">
                <label class="control-label col-sm-3">
                    <font data-localize="frame_xtgl.mmxg_yhm"><b>学生姓名:</b></font>：
                </label>

                <span class="control-value col-sm-9" id="spanCourseName">
                    <input type="text" name="studentName" id="studentName"><br/>
                </span>
            </div>

            <div class="form-group">
                <label class="control-label col-sm-3">
                    <font data-localize="frame_xtgl.mmxg_yhm"><b>学生学号:</b></font>：
                </label>

                <span class="control-value col-sm-9" id="spanstudentNumber">
                    <input type="text" name="studentNumber" id="studentNumber"><br/>
                </span>
            </div>

            <div class="form-group">
                <label class="control-label col-sm-3">
                    <font data-localize="frame_xtgl.mmxg_mm"><b>学生班级:</b></font>：
                </label>

                <div class="col-sm-4">
                    <select id="selectId_id" name="studentClass">
                    </select>
                    <span class="symbol required"></span>
                </div>
                <label class="control-label">
                </label>
            </div>

            <div class="form-group">
                <div class="col-md-offset-3 col-sm-9">
                    <button type="button" class="btn btn-green" onclick="addStudent()">添加</button>
                </div>
            </div>

        </form>
    </div>


    <!-- start: 必要脚本 -->

    <script src="${pageContext.request.contextPath}/js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript">

       function addStudent() {

           var studentName = $("#studentName").val();
           var studentNumber = $("#studentNumber").val();
           var options = $("#selectId_id option:selected");
           var studentClass = options.val();

           if(studentName == "") {
               alert("学生姓名不能为空");
           }else if(studentClass==null) {
               alert("你还未添加班级信息,请添加班级信息");
           }else if(studentNumber == "") {
               alert("学号不能为空");
           }else {
               $.ajax({
                   type: "post",
                   url: "${pageContext.request.contextPath}/student/addStudent",
                   data:{studentNumber:studentNumber,studentClass:studentClass,studentName:studentName},
                   dataType:'json',
                   success: function (data) {
                       if(data.error==0) {
                           alert("添加成功");
                       }else if(data.error==102) {
                           alert("该学生信息已存在，请勿重复添加");
                       }
                   },
                   error: function () {
                       alert("请求失败");
                   }
               })
           }
}

</script>
    <input type="text" id="teacherNumber" hidden="hidden" value="<shiro:user><shiro:principal/></shiro:user>">

    <script>

        //查询教师的班级列表
        $(function(){

            var teacherNumber = $("#teacherNumber").val();

            $.ajax({
                type: 'GET',
                url:'${pageContext.request.contextPath}/studentClass/getGradeList',
                data: {teacherNumber:teacherNumber},
                dataType:'json',
                timeout: 50000,

                success: function (result) {
                    if(result.error == 100) {
                        alert("您暂未添加任何班级,请先添加班级");
                    }
                },

                error: function (xhr, type) {
                    alert('请求出错');
                }
            });
        });
    </script>

    <!-- jquery-ui -->
    <script src="${pageContext.request.contextPath}/resources/plugins/jquery-ui/jquery-ui-1.10.2.custom.min.js"></script>


    <!-- jquery-ui -->
    <script src="${pageContext.request.contextPath}/resources/plugins/bootstrap-3.3.5-dist/js/bootstrap.min.js"></script>


    <!-- blockUI -->
    <script src="${pageContext.request.contextPath}/resources/plugins/blockUI/jquery.blockUI.js"></script>


    <!-- 单选/多选 插件 -->
    <script src="${pageContext.request.contextPath}/resources/plugins/iCheck/jquery.icheck.min.js"></script>


    <!-- 下拉插件 -->
    <script src="${pageContext.request.contextPath}/resources/plugins/select2-master/dist/js/select2.min.js"></script>


    <!-- jquery.cookie -->
    <script src="${pageContext.request.contextPath}/resources/plugins/jquery-cookie/jquery.cookie.js"></script>
    <!-- end: 必要脚本 -->
    <!-- 滚动条 -->


    <!-- 滚动条 -->
    <script src="${pageContext.request.contextPath}/resources/plugins/perfect-scrollbar/src/jquery.mousewheel.js"></script>
    <script src="${pageContext.request.contextPath}/resources/plugins/perfect-scrollbar/src/perfect-scrollbar.js"></script>
    <!-- 提示框 -->


    <!-- 提示框 -->
    <script src="${pageContext.request.contextPath}/resources/plugins/bootbox/bootbox.min.js"></script>
    <!-- moment -->


    <!-- 时间工具 -->
    <script src="${pageContext.request.contextPath}/resources/plugins/moment/min/moment.min.js"></script>
    <script src="${pageContext.request.contextPath}/resources/plugins/moment/locale/zh-cn.js"></script>
    <!-- 表单验证 -->


    <!-- 表单验证 -->
    <script src="${pageContext.request.contextPath}/resources/plugins/jQuery-Validation-Engine-master/js/jquery.validationEngine.js"></script>

    <script>
        function getCookie(name)//取cookies函数
        {
            var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
            if (arr != null) return unescape(arr[2]);
            return null;
        }

        try {
            if (getCookie('jdLanguage') == 'en') {
                document.write('<scr' + 'ipt src="${pageContext.request.contextPath}/resources/plugins/jQuery-Validation-Engine-master/js/languages/jquery.validationEngine-en.js"></scr' + 'ipt>');
            } else {
                document.write('<scr' + 'ipt src="${pageContext.request.contextPath}/resources/plugins/jQuery-Validation-Engine-master/js/languages/jquery.validationEngine-zh_CN.js"></scr' + 'ipt>');
            }
        } catch (e) {
            document.write('<scr' + 'ipt src="${pageContext.request.contextPath}/resources/plugins/jQuery-Validation-Engine-master/js/languages/jquery.validationEngine-zh_CN.js"></scr' + 'ipt>');
        }

        //请求登录老师所对应的课程
        $(function () {
            $.ajax({
                type: "get",
                url: "${pageContext.request.contextPath}/course/getCourse",
                success: function (data) {
                    var data = JSON.parse(data);
                    var html = "";
                    $.map(data.data, function (date, index) {
                        html += "<option value='" + date.courseName + "'>" + date.courseName+ "</option>"

                    })
                    $("#selectId").append(html)
                },
                error: function () {
                    alert("暂无添加课程");
                }
            })
        })

        //获取到选中的options的值
        function readOptionValue() {
            var os = document.getElementById("optionVlaue");
            var msg="选中项";
            for(var i = 0; i < os.length;i++) {
                if(os.options[i].selected() == true) {
                    msg+="" + i + ":" + os.options(i).text;
                }
            }

        }


        //请求当前老师所授班级
        $(function () {
            $.ajax({
                type: "get",
                url: "${pageContext.request.contextPath}/studentClass/getClass",
                success: function (data) {
                    var data = JSON.parse(data);
                    var html = "";

                    $.map(data.data, function (date, index) {
                        html += "<option value='" + date.className + "'>" + date.className+ "</option>"

                    })
                    $("#selectId_id").append(html)
                },
                error: function () {
                    alert("暂无添加课程");
                }
            })
        })
    </script>


    <!-- 日期插件 -->


    <!-- 日期插件 -->
    <script src="${pageContext.request.contextPath}/resources/plugins/bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js">
        //请求登录老师所对应的
    </script>
    <!-- ztree -->


    <!-- ztree -->
    <script type="text/javascript" src="${pageContext.request.contextPath}/resources/plugins/zTree_v3/js/jquery.ztree.all-3.5.min.js"></script>
    <!-- 移动端 -->


    <!-- jquery.touchSwipe 手势 -->
    <script src="${pageContext.request.contextPath}/resources/plugins/TouchSwipe/jquery.touchSwipe.min.js"></script>


    <!-- jquery.velocity 动画插件 -->
    <script src="${pageContext.request.contextPath}/resources/plugins/velocity/jquery.velocity.min.js"></script>


    <!-- 文件上传 -->
    <!--[if lt IE 10]>
    <script src="${pageContext.request.contextPath}/resources/plugins/uploadify/jquery.uploadify.min.js"></script>
    <![endif]-->
    <!--[if gte IE 10]><!-->
    <script src="${pageContext.request.contextPath}/resources/plugins/uploadifive/jquery.uploadifive.min.js"></script>
    <script src="${pageContext.request.contextPath}/resources/js/content-type.js"></script>
    <!--<![endif]-->
    <!-- 框架 -->


    <!-- start: CORE JAVASCRIPTS -->
    <script src="${pageContext.request.contextPath}/resources/js/syscode_init.js"></script>
    <script src="${pageContext.request.contextPath}/resources/js/syscode.js"></script>
    <script src="${pageContext.request.contextPath}/resources/js/main.js"></script>
    <script src="${pageContext.request.contextPath}/resources/js/frame-tool-tab-model.js"></script>
    <script src="${pageContext.request.contextPath}/resources/js/language.js"></script>
    <!-- end: CORE JAVASCRIPTS -->
    <script>
        tool.userloginid = 'chengongsuo';
        tool.usertype = '1, 2, 3, 4, 5';
        tool.group = '15122910383306910022,';
        $(document).ready(function () {
            if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
                var ieversion = new Number(RegExp.$1);
                if (ieversion == 8) {
                    isIE8 = true;
                    $body.addClass('isIE8');
                } else if (ieversion == 9) {
                    isIE9 = true;
                    $body.addClass('isIE9');
                }
            }
            if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
                isMobile = true;
                $body.addClass('isMobile');
            }
            $('.form-horizontal').each(function () {
                var $form = $(this);
                if (isBlank($form.attr('data-action'))) {
                    $form.attr('data-action', window.location.href);
                    if (window.location.href.indexOf("action") < 0) {//spring mvc
                        $form.find("#yspager_currentPageno").attr("name", "currentPageno");
                        $form.find("#eachPageRows").attr("name", "eachPageRows");
                    }
                }
            });
            $('.tabModel-content').removeClass('hide').addClass("fadeInUp").one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
                $(this).removeClass("fadeInUp");
            });
            Main.initTabModel();
        });
    </script>
    <!-- 动画滚动 -->

    <!-- ScrollToFixed -->

    <!-- end: BODY -->


    <script>
        var deltitle = '';
        var errtip = '';

        function getCookie(name)//取cookies函数
        {
            var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
            if (arr != null) return unescape(arr[2]);
            return null;
        }

        var cookielang = getCookie("jdLanguage");
        if (cookielang == "en") {
            deltitle = 'Passwords are not consistent';
            errtip = 'Operation failed, please try again!';
        } else {
            deltitle = '2次输入密码不一致';
            errtip = '操作失败,请重试!';
        }
        subPage = {
            equalpwd: function (id) {
                if (checkStrong(document.getElementById(id).value) < 2) {
                    return "密码强度过低，至少要包含数字，英文，特殊字符中的两种，长度6到20位!";
                }
                var userpwd = $('#userpwd').val();
                var reuserpwd = $('#reuserpwd').val();
                if (userpwd != null && userpwd != '' && reuserpwd != null && reuserpwd != '' && userpwd != reuserpwd) {
                    return deltitle;
                }
                if (userpwd == reuserpwd) {
                    if (id == 'userpwd' && $('#reuserpwd').parent().find('div').hasClass('formError')) {
                        $('#reuserpwd').parent().find('div.formError').remove();
                    } else if ($('#userpwd').parent().find('div').hasClass('formError')) {
                        $('#userpwd').parent().find('div.formError').remove();
                    }
                }
                return '';
            },
            saveUserInfo: function (el) {
                var form_element = $(el).parents(".form-horizontal");
                if (form_element.validationEngine('validate')) {
                    $.ajax({
                        url: tool.initParams(form_element.attr("data-action")),
                        cache: false,
                        type: "post",
                        data: form_element.serialize(),
                        timeout: 1000 * 10,
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            tool.alertWarning(errtip);
                        },
                        success: function (data) {
                            data = eval('(' + data + ')');
                            if (data.oper_res) {
                                tool.alertSuccess(data.oper_msg);
                                parent.closePass();
                            } else {
                                tool.alertWarning(data.oper_msg);
                            }
                        }
                    });
                }
            }
        }


        $(document).ready(function () {
            var pwd = '';
            if (pwd != null && pwd != '') {
                parent.document.getElementById('pwd').value = pwd;
            }
            var oTips = document.getElementById("tips");
            var oInput = document.getElementById("userpwd");
            var aSpan = oTips.getElementsByTagName("span");
            var aStr = ["弱", "中", "强", "非常好"];
            var i = 0;
            oInput.onkeyup = oInput.onfocus = oInput.onblur = function () {
                var index = checkStrong(this.value);
                //this.className = index ? "form-control " : "form-control ";
                oTips.className = "s" + index;
                for (i = 0; i < aSpan.length; i++)
                    aSpan[i].className = aSpan[i].innerHTML = "";
                if (index == 4) {
                    index && (aSpan[index - 1].className = "active", aSpan[index - 1].innerHTML = aStr[index - 1]);
                    index && (aSpan[index - 2].className = "active", aSpan[index - 2].innerHTML = aStr[index - 2]);
                    index && (aSpan[index - 3].className = "active", aSpan[index - 3].innerHTML = aStr[index - 3]);
                    index && (aSpan[index - 4].className = "active", aSpan[index - 4].innerHTML = aStr[index - 4]);
                } else if (index == 3) {
                    index && (aSpan[index - 1].className = "active", aSpan[index - 1].innerHTML = aStr[index - 1]);
                    index && (aSpan[index - 2].className = "active", aSpan[index - 2].innerHTML = aStr[index - 2]);
                    index && (aSpan[index - 3].className = "active", aSpan[index - 3].innerHTML = aStr[index - 3]);
                } else if (index == 2) {
                    index && (aSpan[index - 1].className = "active", aSpan[index - 1].innerHTML = aStr[index - 1]);
                    index && (aSpan[index - 2].className = "active", aSpan[index - 2].innerHTML = aStr[index - 2]);
                } else if (index == 1) {
                    index && (aSpan[index - 1].className = "active", aSpan[index - 1].innerHTML = aStr[index - 1]);
                }
            };
        });

        function checkStrong(sValue) {
            var modes = 0;
            if (sValue.length == 0)
                return 0;
            if (sValue.length < 6)
                return 1;
            if (/\d/.test(sValue))
                modes++;
            //数字
            if (/[a-z]/.test(sValue))
                modes++;
            //小写
            if (/[A-Z]/.test(sValue))
                modes++;
            //大写
            if (/\W/.test(sValue))
                modes++;
            //特殊字符
            switch (modes) {
                case 1:
                    return 1;
                    break;
                case 2:
                    return 2;
                case 3:
                case 4:
                    return sValue.length < 12 ? 3 : 4;
                    break;
            }
        }

    </script>
    <style type="text/css">
        #tips {
            float: left;
        }

        #tips span {
            float: left;
            width: 50px;
            height: 30px;
            color: #fff;
            overflow: hidden;
            background: #ccc;
            margin-right: 3px;
            line-height: 30px;
            text-align: center;
        }

        #tips.s1 .active {
            background: #f30;
        }

        #tips.s2 .active {
            background: #fc0;
        }

        #tips.s3 .active {
            background: #cc0;
        }

        #tips.s4 .active {
            background: #090;
        }
    </style>

</div>
